package hhs.poc.activities.whoiswho;

import java.util.ArrayList;
import java.util.HashMap;

import android.database.Cursor;
import android.util.Log;

public class Employee implements Settable {
	private int id = 0;
	private String name = "";
	private String job = "";
	private String email = "";
	private String academy = "";
	private String phone = "";
	private String room = "";
	private String present = "";

	public Employee() {

	}

	public Employee(String name, String job, String email, String academy,
			String phone, String room, String present) {
		this.name = name;
		this.job = job;
		this.email = email;
		this.academy = academy;
		this.phone = phone;
		this.room = room;
		this.present = present;
	}

	public Employee(int id, String name, String job, String email,
			String academy, String phone, String room, String present) {
		this.id = id;
		this.name = name;
		this.job = job;
		this.email = email;
		this.academy = academy;
		this.phone = phone;
		this.room = room;
		this.present = present;
	}

	public HashMap<String, Boolean[]> getPresentAsHashMap() {
		HashMap<String, Boolean[]> hm = new HashMap<String, Boolean[]>();
		String[] present_parts = present.split(" ");

		int bool_count = 0;
		Boolean[] bool_array = new Boolean[3];
		ArrayList<Boolean[]> array_list = new ArrayList<Boolean[]>();
		for (String part : present_parts) {
			if (bool_count <= 2) {
				bool_array[bool_count] = Boolean.parseBoolean(part);
				bool_count += 1;
			} else {
				array_list.add(bool_array);
				bool_array = new Boolean[3];
				bool_count = 0;
				bool_array[bool_count] = Boolean.parseBoolean(part);
				bool_count += 1;
			}

		}
		array_list.add(bool_array);

		int day_count = 0;
		String[] days = new String[] { "monday", "tuesday", "wednesday",
				"thursday", "friday" };
		for (String day : days) {
			hm.put(day, array_list.get(day_count));
			day_count += 1;
		}

		return hm;
	}

	public String getPresent() {
		return present;
	}

	public void setPresent(String present) {
		this.present = present;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getJob() {
		return job;
	}

	public void setJob(String job) {
		this.job = job;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getAcademy() {
		return academy;
	}

	public void setAcademy(String academy) {
		this.academy = academy;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getRoom() {
		return room;
	}

	public void setRoom(String room) {
		this.room = room;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setAll(Cursor cursor) {
		setId(cursor.getInt(0));
		setName(cursor.getString(1));
		setJob(cursor.getString(2));
		setEmail(cursor.getString(3));
		setAcademy(cursor.getString(4));
		setPhone(cursor.getString(5));
		setRoom(cursor.getString(6));
		setPresent(cursor.getString(7));
	}
}
